#include <bits/stdc++.h>
using namespace std;

int d[100001],v[100001],a[100001],p[100001];

void solve()
{
	int i,m,n,L,V,sum=0,flag=0;
    
    cin>>n>>m>>L>>V;
    
    for(i=1;i<=n;i++)
    {
		cin>>d[i]>>v[i]>>a[i];
		
		if(a[i]!=0)
		{
			flag=1;
		}
	}
	
	for(i=1;i<=m;i++)
	{
		cin>>p[i];
	}
	
	if(flag==0)
	{
		for(i=1;i<=n;i++)
	    {
			if(d[i]<=p[m] && v[i]>V)
		    {
			    sum++;
		    }
		}
		if(sum==0)
	    {
		    cout<<0<<" "<<m<<endl;
	    }
	    else
	    {
		    cout<<sum<<" "<<m-1<<endl;
	    }
	}
	else
	{
		for(i=1;i<=n;i++)
	    {
			if(d[i]<=p[m] && sqrt((p[m]-d[i])*a[i]*2+pow(v[i],2))>V)
		    {
		        sum++;
		    }
		}
		if(sum==0)
	    {
		    cout<<0<<" "<<m<<endl;
	    }
	    else
	    {
		    cout<<sum<<" "<<m-1<<endl;
	    }
	}
}
int main() 
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

   int T;
   
   cin>>T;
   
   while(T--)
   {
	   solve();
   }
   
   return 0;
}
